import 'package:flutter/material.dart';
import 'package:pkg_obz/widgets/text_widgets.dart';

/// Create： Zhang 4/21/21 2:37 PM
/// 描述：按钮样式

///通用按钮
Widget commonButton(
  String text, {
  required VoidCallback onClick,
  EdgeInsetsGeometry margin = const EdgeInsets.only(top: 20),
  double width = double.infinity,
  double height = 45,
  Color bgColor = const Color(0xff25AE5F),
  Color textColor = const Color(0xffffffff),
}) {
  return Container(
    width: width,
    height: height,
    margin: margin,
    decoration: BoxDecoration(
      borderRadius: BorderRadius.circular(5.0),
      color: bgColor,
    ),
    child: TextButton(
      onPressed: onClick,
      style: ButtonStyle(
        overlayColor:
            MaterialStateProperty.resolveWith((states) => Colors.transparent),
      ),
      child: commonText(
        text,
        color: textColor,
        fontWeight: FontWeight.w600,
      ),
    ),
  );
}

///带一个icon的按钮
Widget commonIconButton(
  String text, {
  Color color = const Color(0xff4F4F4F),
  double fontSize = 14,
  EdgeInsetsGeometry? padding,
  EdgeInsetsGeometry? margin,
  FontWeight? fontWeight,
  AlignmentGeometry? alignment,
  Color bgColor = Colors.transparent,
  double bgBorderRadius = 0,
  VoidCallback? onClick,
  double iconSize = 10,
}) {
  return Container(
    alignment: alignment,
    margin: margin,
    padding: padding,
    decoration: BoxDecoration(
      color: bgColor,
      borderRadius: BorderRadius.circular(bgBorderRadius),
    ),
    child: InkWell(
      highlightColor: Colors.transparent,
      splashColor: Colors.transparent,
      onTap: onClick,
      child: Row(
        children: [
          Text(
            text,
            style: TextStyle(
              fontSize: fontSize,
              color: color,
              fontWeight: fontWeight,
            ),
          ),
          Padding(
            padding: const EdgeInsets.only(left: 4, top: 2),
            child: Icon(
              Icons.arrow_forward_ios_rounded,
              color: color,
              size: iconSize,
            ),
          )
        ],
      ),
    ),
  );
}

///使组件具有点击能力
clickAble({required Widget child, required VoidCallback onClick}) {
  return InkWell(
    splashColor: Colors.transparent,
    highlightColor: Colors.transparent,
    child: child,
    onTap: onClick,
  );
}
